package com.yinkgh.mybatis.business.durationrecord.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.yinkgh.demo.HelloApplication;
import com.yinkgh.mybatis.base.exception.BaseException;
import com.yinkgh.mybatis.business.durationrecord.model.DurationRecordInfoPo;
import com.yinkgh.mybatis.business.durationrecord.service.IDurationRecordInfoService;

@RestController
//@Controller
@RequestMapping("/dut")
@SpringBootApplication
public class DurationController {
	
	@Autowired
	private IDurationRecordInfoService durationRecordInfoService;
	
	@RequestMapping("/showList")
	@ResponseBody
    public ModelAndView showIndex(){
		ModelAndView modelAndView = new ModelAndView("durationrecord/list");
		modelAndView.addObject("authType", "1");
        return modelAndView;
    }
	
	@RequestMapping("/dutList")
	@ResponseBody
    public List<DurationRecordInfoPo> dutList(HttpServletRequest request, HttpServletResponse response){
		List<DurationRecordInfoPo> infoPos = new ArrayList<DurationRecordInfoPo>();
		try {
			DurationRecordInfoPo po = new DurationRecordInfoPo();
			infoPos = durationRecordInfoService.selectByModelPaging(po);
			System.out.println(infoPos);
		} catch (BaseException e) {
			e.printStackTrace();
		}
		return infoPos;
    }
	
	public static void main(String[] args) {
        SpringApplication.run(HelloApplication.class, args);
    }
}
